<template>
    <div class="conbox" id="apply_way">
		<view class="uni-padding-wrap uni-common-mt">
			<form>
				<view class="uni-form-item uni-column">
					<text class="title">当前可提现余额</text>
					<text class="right_text">{{cash}}</text>
				</view>
				<view class="uni-form-item uni-column">
					<text class="title">真实姓名</text>
					<text class="right_text">{{real_name}}</text>
				</view>
				<view class="uni-form-item uni-column">
					<text class="title">身份证号</text>
					<text class="right_text">{{Idnum}}</text>
				</view>
				<view class="uni-form-item uni-column">
					<text class="title">银行</text>
					<text class="right_text">{{bankname}}</text>
				</view>
				<view class="uni-form-item uni-column">
					<text class="title">银行卡号</text>
					<text class="right_text">{{bank_card}}</text>
				</view>
				<view class="uni-form-item uni-column">
					<text class="title">手机号码</text>
					<text class="right_text">{{bank_mobile}}</text>
				</view>
				<div class="lab_line"></div>
				<view class="uni-form-item uni-column apply_money">
					<span class='require'>*</span>
					<text class="title especal">申请提现金额</text>
					<input class="uni-input" name="amount" v-model="amount" type="number" placeholder="请输入可提现金额"/>
				</view>
				<view class="uni-list">
					<view class="uni-list-cell">
						<view class="uni-list-cell-left">
							当前选择
						</view>
						<view class="uni-list-cell-db">
							<picker @change="bindPickerChange" :value="deposit_mode" :range="columns" mode='selector' class="selctpicker">
								<view class="uni-input">{{applyway}}</view>
							</picker>
						</view>
					</view>
				</view>
				<view class="uni-form-item uni-column">
					<text class="title">提现描述</text>
					<input class="uni-input" name="withdradesc" v-model="withdradesc" placeholder="请输入提现描述"/>
				</view>
			</form>
		</view>
		<footer>
			<ul class="operation">
				<li @click="reset">重置</li>
				<li @click="savemsg">保存</li>
				<!--<li>
					<button  type="default" formType="reset">重置</button>
				</li>
				<li>
					<button formType="submit">保存</button>
				</li>-->
			</ul>
		</footer>
    </div>
</template>

<script>
import { getuserpass, sendcashmay } from '@/api/payment'
export default {
	name: 'cashWithdrawal',
	data() {
		return {
			cash: 0,
			index: 0,
			real_name: '',
			Idnum: '',
			bankname: '',
			bank_card: '',
			bank_mobile: '',
			amount: '',
			applyway: '请选择支付方式',
			withdradesc: '',
			deposit_mode: 0,
			real_id: '',
			showPicker: false,
			columns: ['线下打款', '会员余额'],
			owner_user_id: ''
		}
	},
	mounted() {
		this.getcashdrawl()
	},
	onLoad(opcation) {
		this.owner_user_id = opcation.owner_user_id
		this.cash = opcation.cash
		this.real_id = opcation.real_id
	},
	methods: {
		getcashdrawl() {
			let data = {
				ru_id: this.owner_user_id
			}
			getuserpass(data).then(res => {
				if (res.status == 'success') {
					this.cash = res.data.seller_money
					this.real_name = res.data.real_name
					this.real_id = res.data.real_id
					this.Idnum = res.data.self_num
					this.bankname = res.data.bank_name
					this.bank_card = res.data.bank_card
					this.bank_mobile = res.data.bank_mobile
				} else {
					this.msg(res.message)
				}
			})
		},
		msg(msg) {
			uni.showToast({
				title: msg,
				icon: 'none'
			})
		},
		bindPickerChange: function(e) {
			this.deposit_mode = e.target.value
			this.applyway = this.columns[e.target.value]
		},
		reset() {
			this.amount = ''
			this.applyway = ''
			this.deposit_mode = ''
			this.withdradesc = ''
		},
		savemsg() {
			uni.showLoading({
				title: '请求中...',
				mask: true
			})
			if (this.amount == '') {
				this.msg('请输入提现金额')
			} else if (!this.deposit_mode && this.deposit_mode != 0) {
				this.msg('请选择提现方式')
			} else if (this.withdradesc == '') {
				this.msg('请输入提现描述')
			} else if (this.amount > this.cash) {
				this.msg('超出可提现余额')
			} else {
				let data = {
					ru_id: this.owner_user_id,
					real_id: this.real_id,
					amount: this.amount,
					deposit_mode: this.deposit_mode,
					seller_note: this.withdradesc
				}
				sendcashmay(data).then(res => {
					uni.hideLoading()
					if (res.status == 'success') {
						this.reset()
						this.msg(res.data)
						setTimeout(() => {
							uni.redirectTo({
								url: '/pages/admin/index'
							})
						}, 500)
					} else {
						this.msg(res.errors.message)
					}
				})
			}
		}
	}
}
</script>

<style scoped>
	.uni-padding-wrap{
		width: 750px;
		height: auto;
		padding: 0;
		display: flex;
		background: white;
	}
	#apply_way .uni-form-item {
		width: 690px;
		margin: 0 30px;
		display: block;
		float:left;
		padding: 20px 0;
		font-size: 25px;
		border-bottom: 1px solid #eeeeee;
	}
	#apply_way .uni-form-item:last-child{
		border-bottom:none;
	}
	#apply_way .apply_money{
		border-bottom:none;
	}
	#apply_way .title {
		width: 30%;
		float: left;
		display: inline;
		padding-left: 0;
	}
	#apply_way .especal{
		width: 28%;
	}
	.require{
		float: left;
		color:red;
/*		line-height: 60px;*/
		margin-right: 2px;
		padding: 10px 0;
	}
	#apply_way .uni-column .uni-input {
		float: left;
		display: inline;
	}
	.right_text{
		float: right;
	}
	.formdata{
		width: 100%;
		height: auto;
		background: white;
	}
	.formdata li{
		width: 94%;
		height: 100px;
		line-height: 100px;
		border-bottom: 1px solid #eeeeee;
	}
	.formdata li:last-child{
		border-bottom:none;
	}
	.lab_line{
		height: 20px;
		width: 100%;
		float: left;
		background: #F5F5F5;
	}

	#apply_way .uni-list{
		width: 690px;
		margin-left: 30px;
		border-top:0;
		padding: 25px 0;
	}
	#apply_way .uni-list-cell-left{
		padding: 0;
	}
	#apply_way .selctpicker .uni-input{
		width: 40%;
		margin-left: 21%;
	}
	.operation li{
		height: 100%;
		float: left;
		line-height: 100px;
		font-size: 32px;
		text-align: center;
	}
	.operation li:first-child{
		width: 30%;
	}
	.operation li:nth-child(2){
		color: #3A1B04;
		width: 70%;
		background: #FFD11A;
	}
</style>
